<?php require_once('../Connections/agriculture.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO fmanage (fmanage_crop, fmanage_symptom, fmanage_time, fmanage_method) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['textfield'], "text"),
                       GetSQLValueString($_POST['textarea'], "text"),
                       GetSQLValueString($_POST['textarea2'], "text"),
                       GetSQLValueString($_POST['textarea3'], "text"));

  mysql_select_db($database_agriculture, $agriculture);
  $Result1 = mysql_query($insertSQL, $agriculture) or die(mysql_error());
}
?><div ><a href="stianjian.php">查看信息</a></div>
        <div ><a href="wtianjian.php">录入信息</a></div>
      <div ><a href="drtianjian.php">修改/删除信息</a></div>
      <div ><a href="out.php">退出登陆</a></div>
	  <p><br>
</p>
      <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
        <p>录入田间管理信息</p>
        <p>名称:
          <label>
          <input type="text" name="textfield" />
          </label>
        </p>
        <p>症状:
          <label>
          <textarea name="textarea"></textarea>
          </label>
        </p>
        <p>时间:
          <label>
          <textarea name="textarea2"></textarea>
          </label>
        </p>
        <p>处理方法:
          <label>
          <textarea name="textarea3"></textarea>
          </label>
        </p>
        <p>
          <label>
          <input type="submit" name="Submit" value="提交" />
          </label>
          <label>
          <input type="reset" name="Submit2" value="重置" />
          </label>
        </p>
        <input type="hidden" name="MM_insert" value="form1">
</form>
      
      <p>&nbsp; </p>
